﻿using System.Collections.Generic;
using System.Linq;
using WeBlog.Interfaces;
using WeBlog.Models;

namespace WeBlog.Repositories
{
    public class PageRepository : RepositoryBase<Page>
    {        
        public PageRepository(IUnitOfWork unitOfWork) : base( unitOfWork )
        {
        }
        
        public Page FindBySlug( string slug )
        {
            return FindAll().SingleOrDefault(x => x.Slug == slug);
        }

        public List<Page> FindPublished()
        {
            return FindAll().Where(x => x.Published == true).OrderBy(x => x.Title).ToList();
        }
    }
}
